import { config } from '@ai/config';
import { CacheInterceptor, CacheModule } from '@nestjs/cache-manager';
import { MiddlewareConsumer, Module, NestModule, OnModuleInit } from '@nestjs/common';
import { APP_INTERCEPTOR } from '@nestjs/core';
import { MongooseModule } from '@nestjs/mongoose';
import { ApiModule } from './api.module';

const { ADMIN_PORT, CLIENT_PORT, MONGODB_URI } = config;

@Module({
    imports: [MongooseModule.forRoot(MONGODB_URI), ApiModule, CacheModule.register({ max: 100, isGlobal: true })],
    providers: [
        {
            provide: APP_INTERCEPTOR,
            useClass: CacheInterceptor,
        },
    ],
})
export class AppModule implements NestModule, OnModuleInit {
    onModuleInit() {}

    configure(consumer: MiddlewareConsumer) {}
}
